<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="../ct-commit.html">

<link rel="import" href="../../model/ct-commit-mock.html">

<script>
(function () {

var assert = chai.assert;

describe('ct-commit', function() {
  var commit;

  beforeEach(function(done) {
    commit = document.createElement('ct-commit');
    commit.data = new CTCommitMock();

    setTimeout(done);
  });

  describe('commit UI', function() {
    function checkCommitInfo() {
      var html = commit.shadowRoot.innerHTML;

      assert.include(html, 'mkwst');
      assert.include(html, 'behavior for these types');
      assert.equal(commit.shadowRoot.querySelector('a').href, commit.data.url);
    }

    function checkNotASuspectedCommit() {
      assert.equal(commit.shadowRoot.querySelector('span'), null);
      assert.equal(commit.shadowRoot.querySelector('a').className, '');
    }

    it('should show example commit', function() {
      checkCommitInfo();
      checkNotASuspectedCommit();
    });

    it('should show unsuspected commit', function(done) {
      commit.suspected = false;

      setTimeout(function(){
        checkCommitInfo();
        checkNotASuspectedCommit();

        done();
      });
    });

    it('should show suspected commit', function(done) {
      commit.suspected = true;

      setTimeout(function(){
        checkCommitInfo();

        assert.equal(commit.shadowRoot.querySelector('span').innerHTML, '*');
        assert.equal(commit.shadowRoot.querySelector('a').className, 'suspected-commit');

        done();
      });
    });
  });
});

})()
</script>
